package com.zytlifeservice.controller.pay;

import com.qianmi.open.api.ApiException;
import com.qianmi.open.api.request.BmDirectRechargeLifeRechargePayBillRequest;
import com.qianmi.open.api.response.BmDirectRechargeLifeRechargePayBillResponse;
import com.zytlifeservice.domain.Result;
import com.zytlifeservice.service.pay.PublicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by MJS on 2017/6/21.
 */

@RestController
@RequestMapping(value = "/debug")
public class DebugController {

    @Autowired
    PublicService publicService;

    @RequestMapping(value = "/payWater")
    public Object testPay() throws ApiException {
        BmDirectRechargeLifeRechargePayBillRequest req = new BmDirectRechargeLifeRechargePayBillRequest();
        req.setItemId("6420401");
        req.setItemNum("1");
        req.setRechargeAccount("0000000222222223333");
        req.setCallback(publicService.getBmCallbackUrl());
        String outTradeNo = "zyt" + 3 + System.currentTimeMillis()
                + (long) (Math.random() * 10000000L);
        req.setOuterTid(outTradeNo);

        BmDirectRechargeLifeRechargePayBillResponse response = publicService.execute(req);
        return response;
    }

}
